//
//  XKHomeHeaderReusableView.m
//  xk100
//
//  Created by xiaokang on 2017/5/17.
//  Copyright © 2017年 xiaokang. All rights reserved.
//

#import "XKHomeHeaderReusableView.h"

@interface XKHomeHeaderReusableView ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *moreLabel;
@property (nonatomic, strong) UIView *bottomLineView;
@end

@implementation XKHomeHeaderReusableView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        
        
        self.titleLabel = [UILabel getLabWithText:@"最新动态" textFont:Font_17 textColor:BlackColor];
        [self addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self).offset(10);
            make.centerY.mas_equalTo(self);
            make.width.mas_equalTo(150);
        }];
        
        
        
        self.moreLabel = [UILabel getLabWithText:@"查看更多" textFont:Font_15 textColor:LightGrayColor textAlignment:NSTextAlignmentRight];
        [self addSubview:self.moreLabel];
        [self.moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self).offset(-10);
            make.centerY.mas_equalTo(self.titleLabel);
        }];
        
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreNewsTapGestureRecognizerEvent:)];
        self.moreLabel.userInteractionEnabled = YES;
        [self.moreLabel addGestureRecognizer:tap];
        
        self.bottomLineView = [UIView new];
        self.bottomLineView.backgroundColor = kBaseGrayColor;
        [self addSubview:self.bottomLineView];
        [self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.mas_equalTo(self);
            make.height.mas_equalTo(1);
        }];
    }
    return self;
}


#pragma mark - moreNewsTapGestureRecognizerEvent
- (void)moreNewsTapGestureRecognizerEvent:(UITapGestureRecognizer *)sender {
    if (self.moreNewsBlock) {
        self.moreNewsBlock();
    }
}
@end
